$(function () {
    $("#page").load("/html/page.html");
});
layui.use("layer");
function findAll() {
    let data = {
        name: $("#name").val(),
        createTime: $("#createTime").val(),
        pageNum: $.trim($("#pageNum").val()),
        pageSize: $.trim($("#pageSize").val())
    }
    let result = myAjax("/permission/searchAll", "post", data);
    if (result.code === 401) {
        layer.msg(result.message);
        window.parent.location.href="/html/login.html";
    }else if (result.code === 200){
        let data = result.data.list;
        $("#pageCount").html(result.data.number)
        show(data);
    }
}
function show(data) {
    let html="";
    for (let i=0;i<data.length;i++){
        html+='<tr>' +
            '  <td><input type="checkbox" name="isCheck" value="' + data[i].id + '">'+data[i].id+'</td>' +
            '  <td>'+data[i].name+'</td>' +
            '  <td>'+data[i].value+'</td>' +
            '  <td>'+data[i].src+'</td>' +
            '  <td>'+data[i].status+'</td>' +
            '  <td>'+data[i].type+'</td>' +
            '  <td>'+data[i].createTime+'</td>' +
            '  <td><input style="border-radius: 5px;' +
            '   background-color: #009E94;width: 80px;height: 30px" ' +
            '   type="button" value="编辑" onclick="editPermission('+data[i].id+')">' +
            '  </td>' +
            '</tr>';
    }
    $("#findAll").html(html);
}
function editPermission(id) {
    sessionStorage.setItem("permissionId",id);
    //弹出一个页面层
    layer.open({
        type: 2,
        anim:3,
        title:'权限编辑',
        area: ['600px', '500px'],
        shadeClose: true, //点击遮罩关闭
        content: ['/html/permission/permissionEdit.html','no'],
    })
}
function addPermission() {
    //弹出一个页面层
    layer.open({
        type: 2,
        anim:3,
        title:'添加权限',
        area: ['600px', '500px'],
        shadeClose: true, //点击遮罩关闭
        content: ['/html/permission/selectParent.html','no'],
    })
}
